<?php
header("Content-type:text/html;charset=utf-8");
require '../cofd/common.php';
$user=$_GET['account2'];
$pass=$_GET['password2'];
$stmt = $conn->prepare("SELECT * FROM user WHERE username = ? AND password = ?");  
$stmt->bind_param("ss", $user, $pass); 
$stmt->execute();  
$result = $stmt->get_result(); 
$row = $result->fetch_assoc(); 
if ($result->num_rows > 0) {    
    $userId = htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8');
    $userName = htmlspecialchars($row['uname'], ENT_QUOTES, 'UTF-8');
    $tximg = $row['tximg'];
    setcookie('user_key',$userId, 0, '/');
    echo "<script>sessionStorage.setItem('user', '" . $userId . "');</script>";
    echo "<script>sessionStorage.setItem('user_nm', '" . $userName . "');</script>";
    echo "<script>sessionStorage.setItem('sspng', '" . $tximg . "');</script>";
    echo "<script>sessionStorage.setItem('3e2bb4d72ebe48f9', '7dcaee1cfe2c9fb9');</script>";
    echo "<script>sessionStorage.setItem('get_urlone', '1');</script>";
    echo "<script>alert('账号密码正确！登录成功');window.parent.location.href = '/center-person/';</script>";  
} else {  
    echo "<script>alert('管理员账号或密码错误!');location='/center-person/lgreg.php';</script>";  
}   
$stmt->close();  
$conn->close(); 
?>